package com.mall.orders.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.commons.utils.CommonResult;
import com.mall.model.domain.OmsOrderReturnApply;
import com.mall.model.vo.CommonPage;
import com.mall.orders.service.OmsOrderReturnApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * 订单退货申请(OmsOrderReturnApply)表控制层
 *
 * @author wishmumu
 * @since 2023-03-11 15:42:55
 */
@RestController
@RequestMapping("returnApply")
public class OmsOrderReturnApplyController  {
    /**
     * 服务对象
     */
    @Autowired
    private OmsOrderReturnApplyService omsOrderReturnApplyService;

    /**
     * 分页查询退货申请
     * @return 所有数据
     */
    @GetMapping("/list")
    public CommonResult selectAll(Integer pageNum,Integer pageSize,@RequestParam(required = false) Integer id,@RequestParam(required = false)Integer status,
                                  @RequestParam(required = false)String createTime,@RequestParam(required = false)String handleMan,
                                  @RequestParam(required = false)String handleTime,@RequestParam(required = false)String receiverKeyword) {
        CommonPage commonPage = omsOrderReturnApplyService.selectAll(pageNum,pageSize, status, createTime, handleMan, handleTime, receiverKeyword);
        return CommonResult.success(commonPage);
    }

    /**
     * 获取退货申请详情
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/{id}")
    public CommonResult getById(@PathVariable("id") Integer id) {
        OmsOrderReturnApply omsOrderReturnApply = omsOrderReturnApplyService.getById(id);
        return CommonResult.success(omsOrderReturnApply);
    }


    /**
     * 修改数据
     *
     * @param omsOrderReturnApply 实体对象
     * @return 修改结果
     */
    @PostMapping("/update/status/{id}")
    public CommonResult update(@PathVariable("id") Integer id, @RequestBody OmsOrderReturnApply omsOrderReturnApply) {
        omsOrderReturnApplyService.update(id, omsOrderReturnApply);
        return CommonResult.success("success");
    }

    /**
     * 批量删除退货申请
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @PostMapping("/delete")
    public CommonResult delete(@RequestParam("ids") List<Integer> ids) {
        omsOrderReturnApplyService.delete(ids);
        return CommonResult.success("success");
    }
}

